package plus.easydo.magic.api;

import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.core.context.RequestEntity;
import org.ssssssss.magicapi.core.interceptor.ResultProvider;

/**
 * @author yuzhanfeng
 * @Date 2023-11-29 15:45
 * @Description 自定义返回结构
 */
@Component
public class CustomJsonValueProvide implements ResultProvider {
    /**
     *   定义返回结果，默认返回JsonBean
     */
    @Override
    public Object buildResult(RequestEntity requestEntity, int code, String message, Object data) {
        R<Object> r = new R<>();
        r.setCode(code);
        r.setData(data);
        r.setSuccess(code == R.SUCCESS_CODE);
        r.setMessage(message);
        r.setErrorMessage(message);
        return r;
    }
}
